package com.union.core.sys.service;

import java.util.Date;
import java.util.List;

import org.apache.log4j.Logger;

import com.union.core.sys.dao.SysLogsDao;
import com.union.core.sys.dao.impl.SysLogsDaoImpl;
import com.union.core.sys.model.SysLogs;
import com.union.core.sys.model.SysManager;

/**
 * 业务逻辑处理类:系统日志
 * filename: SysLogsService.java
 * project:  CCTR
 * @company Hainan Jowe Technology Ltd
 * @author wangxiuwu
 * @create in 2009-6-1
 * @version 1.0
 */
public class SysLogsService{
	private static Logger log = Logger.getLogger(SysLogsService.class.getName());
	private SysLogsDao sysLogsDaoImpl;
	private SysService sysService=SysService.getInstance();
	public SysLogsService(){
		sysLogsDaoImpl = new SysLogsDaoImpl();
		
	}
	/**
	 * 添加系统日志信息
	 * @param days
	 */
	public void addSysLogs(String messages){
		SysManager sysManager=sysService.getSessionListener();
		SysLogs syslog = new SysLogs();
		if(sysManager.getPERSONNEL()!=null){
			syslog.setOpera_person(sysManager.getPERSONNEL().getPersonnel_name());
			syslog.setMESSAGES(messages);
			syslog.setOpera_orgenization(sysManager.getPERSONNEL().getOrganization_name());
			syslog.setOpera_account(sysManager.getMANAGER_NAME());
			sysLogsDaoImpl.addLogs(syslog);
		}else{
			syslog.setOpera_person("system");
			syslog.setOpera_orgenization("系统");
			syslog.setOpera_account(sysManager.getMANAGER_NAME());
			syslog.setMESSAGES(messages);
			sysLogsDaoImpl.addLogs(syslog);
		}
		log.info("PLAT: 添加系统日志信息");
	}
	/**
	 * 删除系统日志信息
	 * @param days
	 */
	public void deleteSysLogs(int days){
		sysLogsDaoImpl.deleteMore(days);
		log.info("PLAT: 删除系统日志信息:"+new Date());
	}
	
	/**
	 * 查询日志信息列表
	 * @param Level String
	 * @param ParamName String
	 * @param ParamValue String
	 * @param start int
	 * @param PageSize int
	 * @return List<SysLogs>
	 */
	public List<SysLogs> querySysLogs(int GUID,String Date, String messages,String operaPerson,String operaOrgenization,
			String operaAccount,String startDate,String endDate,String ParamName, String ParamValue,String orderBy,int start, int PageSize){
		return sysLogsDaoImpl.getList(GUID,Date, messages, operaPerson, operaOrgenization, operaAccount,startDate,endDate, 
				ParamName, ParamValue, orderBy, start, PageSize);
	}
	
	/**
	 * 查询日志信息列表记录数
	 * @param Level String
	 * @param ParamName String
	 * @param ParamValue String
	 * @return int
	 */
	public int querySysLogsCount(int GUID,String Date, String messages,String operaPerson,String operaOrgenization,
			String operaAccount,String startDate,String endDate,String ParamName, String ParamValue){
		return sysLogsDaoImpl.getListCount(GUID,Date, messages, operaPerson, operaOrgenization,
				operaAccount,startDate,endDate, ParamName, ParamValue);
	}
}
